<?php 

include './fun.php';
session_start();
$data = $_POST;
	if (empty($data["username"])) {
		mistake('错误','用户名为空','./wicket.php',3);
		exit;
	}
	if (empty($data["password"])) {
		mistake('错误','密码为空','./wicket.php',3);
		exit;
	}
	$_SESSION["authCode"] =implode($_SESSION["authCode"] );

	$_SESSION["authCode"] =strtolower($_SESSION["authCode"]);
	$data["authCode"] =strtolower($data["authCode"]);
	// var_dump($data["authCode"]);
	// exit;
	if ($_SESSION["authCode"] != $data["authCode"] ) {

		mistake('错误','验证码错误','./zc.php',5);
		exit;
	}
	unset($data["authCode"]);
	$data['create_time']=time();
	$db1 = include './db1.php';
	foreach ($db1 as $k => $v) {
		if ($data["username"] == $v["username"]) {
			mistake('用户已存在请重新注册','正在','./zc.php',1);
			exit;
		}
	}
	$data["password"]=md5($data["password"]);
	$db1[]=$data;
	$db1 = var_export($db1,true);
	$db1 = "<?php return ".$db1."?>";
	file_put_contents('./db1.php', $db1);
	$_SESSION['username']=$data["username"];
	mistake('注册成功','正在','./wicket.php',1);
	// header("Location:./wicket.php");


 ?>